package com.tinyseed.emcp.api.exception.rest;


import com.tinyseed.emcp.api.exception.bean.ExceptionStatisticsInputDTO;
import com.tinyseed.emcp.api.exception.service.ExceptionStatisticsService;
import com.tinyseed.hmxx.common.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "异常：异常统计")
@Slf4j
@RestController
@RequestMapping("/exceptionStatistics")

public class ExceptionStatisticsController extends BaseController {

    private final ExceptionStatisticsService exceptionStatisticsService;

    public ExceptionStatisticsController(ExceptionStatisticsService exceptionStatisticsService) {
        this.exceptionStatisticsService = exceptionStatisticsService;
    }


    @GetMapping(value = "/list")
    @ApiOperation("分页查询")
    public ResponseEntity list(int size, int current) {
        return new ResponseEntity<>(exceptionStatisticsService.getList(current, size), HttpStatus.OK);

    }

    @GetMapping(value = "/listAll")
    @ResponseBody
    public ResponseEntity list(ExceptionStatisticsInputDTO request, int limit, int page) {
        Page list = exceptionStatisticsService.getList(request, limit, page);
        return new ResponseEntity<>(list, HttpStatus.OK);

    }

}
